// pages/myResume/myResume.js
import { request } from "../../utils/index.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:{}, // 用户信息
    resumeInfo:{}, // 简历信息
    list:[
      {
        id:0,
        text:"添加基本信息"
      },
      {
        id:1,
        text:"添加教育经历"
      },
      {
        id:2,
        text:"添加工作经历"
      },
      {
        id:3,
        text:"添加工作期望"
      },
      {
        id:4,
        text:"添加技能/证书"
      },
      {
        id:5,
        text:"添加自我评价"
      }
    ]
  },

   // 查询用户信息
   getUserInfo () {
    request({ url: "/api/auth/me" })
    .then(result => {
      console.log(result)
      this.setData({
        userInfo:result.data
      })
    })
  },

  // 查询简历信息
  getResume (){
    request({ url: "/api/resume/show" })
    .then(result => {
      console.log(result)
      this.setData({
        resumeInfo:result.data
      })
    })
  },

  // 添加信息
  onAddInfo(event){
    let str=JSON.stringify(this.data.resumeInfo);
    let index = event.currentTarget.dataset.value;
    if (index == 0) {
      wx.navigateTo({
        url: '/pages/basicInfo/basicInfo?jsonStr='+encodeURIComponent(str),
      })
    }else if (index == 1) {
      wx.navigateTo({
        url: '/pages/education/education',
      })
    }else if (index == 2) {
      wx.navigateTo({
        url: '/pages/jobExperience/jobExperience',
      })
    }else if (index == 3) {
      wx.navigateTo({
        url: '/pages/jobExpectation/jobExpectation?jsonStr='+encodeURIComponent(str),
      })
    }else if (index == 4) {
      wx.navigateTo({
        url: '/pages/mySkills/mySkills',
      })
    }else {
      wx.navigateTo({
        url: '/pages/myEvalution/myEvalution?jsonStr='+encodeURIComponent(str),
      })
    }
  },


  onEducation(event) {
    let str=JSON.stringify(event.currentTarget.dataset.value);
    wx.navigateTo({
      url: '/pages/education/education?jsonStr='+encodeURIComponent(str), 
    })
  },

  onJobExperience(event) {
    let str=JSON.stringify(event.currentTarget.dataset.value);
    wx.navigateTo({
      url: '/pages/jobExperience/jobExperience?jsonStr='+encodeURIComponent(str), 
    })
  },

  onSkills(event) {
    let str=JSON.stringify(event.currentTarget.dataset.value);
    wx.navigateTo({
      url: '/pages/mySkills/mySkills?jsonStr='+encodeURIComponent(str), 
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getUserInfo();
    this.getResume();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})